<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('专家转隶审核')" />
</head>
<body class="gray-bg">
    <div class="container-div">
        <div class="row" id="biandongshenhe">

            <!--变动审核-->
            <div>
                <div class="col-sm-12 search-collapse">
                    <form id="formId">
                        <div class="select-list">
                            <ul>
                                <li>
                                    <label style="width: 80px !important;">状态&nbsp;&nbsp;</label>
                                    <select style="width: 150px !important;" name="zhuangtai" v-model="zhuangtai" class="form-control" type="text">
                                        <option value="9">全部</option>
                                        <option value="0">待审核</option>
                                        <option value="1">通过</option>
                                        <option value="2">驳回</option>

                                    </select>
                                </li>
                                <li>
                                    <label style="width: 80px !important;">变动类型&nbsp;&nbsp;</label>
                                    <select style="width: 150px !important;" name="biandongleixing" th:with="type=${@dict.getType('sys_zhuanjiazhuangtai')}" v-model="biandongleixing" class="form-control" type="text">
                                        <option value="8">人事关系转出</option>
                                    </select>
                                </li>
                                <li>
                                    <label style="width: 80px !important;">单位名称&nbsp;&nbsp;</label>
                                    <input style="width: 150px !important;" type="text" name="deptname" v-model="deptname"/>
                                </li>
                                <li>
                                    <label style="width: 80px !important;">专家&nbsp;&nbsp;</label>
                                    <input style="width: 150px !important;" type="text" name="xingming" v-model="xingming"/>
                                </li>
                                <li>
                                    <label style="width: 80px !important;">提交时间&nbsp;&nbsp;</label>
                                    <input style="width: 150px !important;" type="text" class="" placeholder="请选择提交开始日期" name="xiafashijiankaishi" id="xiafashijiankaishi" v-model="xiafashijiankaishi" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" @blur="getDate_chaxun"/>
                                    <input style="width: 150px !important;" type="text" class="" placeholder="请选择提交结束日期" name="xiafashijianjieshu" id="xiafashijianjieshu" v-model="xiafashijianjieshu" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" @blur="getDate_chaxun"/>
                                </li>
                                <li>
                                    <label style="width: 80px !important;">审核时间&nbsp;&nbsp;</label>
                                    <input style="width: 150px !important;" type="text" class="" placeholder="请选择审核开始日期" name="wanchengshijiankaishi" id="wanchengshijiankaishi" v-model="wanchengshijiankaishi" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" @blur="getDate_chaxun"/>
                                    <input style="width: 150px !important;" type="text" class="" placeholder="请选择审核结束日期" name="wanchengshijianjieshu" id="wanchengshijianjieshu" v-model="wanchengshijianjieshu" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" @blur="getDate_chaxun"/>
                                </li>
                                <li class="sousuo">
                                    <a class="btn btn-success btn-md" @click="bindShenheList"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                    <a class="btn btn-warning btn-md" @click="refresh"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                </li>
                            </ul>
                        </div>
                    </form>
                </div>

                <div class="col-sm-12 select-table table-striped">

                    <div style="display: flex">
                        <div class="btn-group-md" id="toolbar" role="group">
                            <button class="btn btn-warning dim" @click="Export">
                                <i class="fa fa-download"></i> 导出
                            </button>
                        </div>
                    </div>

                    <!--列表-->
                    <table id="bootstrap-table" class="table table-hover table-primary table-striped" style="margin-top: 10px;grid-column: 1/-1;grid-row: 2;">
                        <thead>
                            <tr>
                                <th style="text-align: center; vertical-align: middle;">序号</th>
                                <th style="text-align: center; vertical-align: middle;">专家代码</th>
                                <th style="text-align: center; vertical-align: middle;">专家</th>
                                <th style="text-align: center; vertical-align: middle;">特贴单位</th>
                                <th style="text-align: center; vertical-align: middle;">变动类型</th>
                                <th style="text-align: center; vertical-align: middle;">提交时间</th>
                                <th v-if="zhuangtai!=0" style="text-align: center; vertical-align: middle;">审核时间</th>
                                <th style="text-align: center; vertical-align: middle;">最新状态</th>
                                <th style="text-align: center; vertical-align: middle;">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr v-for="(shenheitem,index) in shenhelist"  v-if="shenhelist.length > 0">
                                <td style="vertical-align: middle; text-align: center;" v-text="index+1"></td>
                                <td style="vertical-align: middle; text-align: center;" v-text="shenheitem.zhuanjiaid"></td>
                                <td style="vertical-align: middle; text-align: center;" v-text="shenheitem.xingming"></td>
                                <td style="vertical-align: middle; text-align: center;" v-text="shenheitem.tjdeptname"></td>
                                <td style="vertical-align: middle; text-align: center;" v-text="shenheitem.biandongleixing_txt"></td>
                                <td style="vertical-align: middle; text-align: center;" v-text="shenheitem.renwuxiafashijian"></td>
                                <td v-if="zhuangtai!=0" style="vertical-align: middle; text-align: center;" v-text="shenheitem.renwuwanchengshijian"></td>
                                <td style="vertical-align: middle; text-align: center;" v-text="shenheitem.zxdeptname+'('+shenheitem.zuixinzhuangtai+')'"></td>
                                <td style="vertical-align: middle; text-align: center;" v-text="">
                                    <button v-if="shenheitem.shifouwancheng==0" class="btn btn-warning btn-md" @click="showShenheModal(shenheitem.renwuid)">审核</button>
                                    <button v-if="shenheitem.shifouwancheng==0&&shenheitem.接收单位id==deptid" class="btn btn-warning btn-md" @click="jieshou(shenheitem.renwuid)">接收</button>
                                    <button class="btn btn-info btn-md" @click="showDetailModal(shenheitem.shenbaoid)">查看</button>
                                    <button class="btn btn-info btn-md" @click="showShenhejiluModel(shenheitem.shiwuid)">审核进度</button>
                                </td>
                            </tr>
                            <tr v-if="shenhelist.length == 0">
                                <td style="text-align: center; vertical-align: middle" colspan="9">查无数据</td>
                            </tr>
                        </tbody>
                    </table>
                    <!--翻页-->
                    <div v-if="recordCount != '0'" class="my-page-navigation" style="text-align:center;margin-left: auto;">
                        <button class="btn btn-default" @click="firstPage">首页</button>
                        <button class="btn btn-default" @click="prePage">上一页</button>
                        <select class="custom-select border-secondary" v-model="pagesize">
                            <option value="10">10 条/页</option>
                            <option value="20">20 条/页</option>
                            <option value="30">30 条/页</option>
                            <option value="50">50 条/页</option>
                        </select>
                        <span v-text="pageindex + '  /  ' + pageCount" style="border-color: #6c757d"></span>
                        <span v-text="'共' + recordCount + '条'" style="border-color: #6c757d"></span>
                        <button class="btn btn-default" @click="nextPage">下一页</button>
                        <button class="btn btn-default" @click="lastPage">尾页</button>
                        <span style="border-color: #6c757d">跳到第</span>
                        <input type="text" class="form-control border-secondary" style="width:50px;display:inline;" v-model="targetpage" @keyup.enter="targetPage">
                        <span style="border-color: #6c757d">页</span>
                        <button class="btn btn-default" @click="targetPage">跳</button>
                    </div>
                </div>
            </div>

            <!-- 审核记录-->
            <div th:replace="system/zhuanjia/modal_shenhejilu::shenhejilu"></div>
            <!-- 查看专家变动详情信息 -->
            <div th:replace="system/zhuanjia/modal_detail::detail_detail"></div>
            <!-- 审核弹窗 -->
            <div th:replace="system/zhuanjia/modal_zhuanlishenhe::shenhe"></div>

        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: WdatePicker" />
    <script>

        var vm_biandongshenhe = new Vue({
            el : "#biandongshenhe",
            data : {
                deptid : $("#deptid").val(),		// 单位ID
                deptname : $("#deptname").val(),		// 单位ID

                //查询用字段
                zhuangtai : "9",
                biandongleixing : '8',
                deptname : '',
                xingming : '',
                xiafashijiankaishi : '',
                xiafashijianjieshu : '',
                wanchengshijiankaishi : '',
                wanchengshijianjieshu : '',

                shenhelist : [],//专家变动审核列表
                shenhejilulist : [],//专家变动审核记录
                deptlist:[],//审核转移下级单位列表

                biandong:{},//详情
                renwuid:'',//当前shenhe的renwuid
                shenbaoid:'',//当前detail的shenbaoid

                //审核
                zhuanyideptid:'',
                shenheyijian:'',

                pageindex : 1,		// 查询分页初始化页
                pagesize : 10,		// 查询分页初始化页面大小
                pageCount : 0,		// 总页数
                recordCount : 0,	// 总记录数
                targetpage : '', 	// 目标页

            },
            created : function(){
                var _this = this;

                _this.bindShenheList();
                _this.bindDeptList();
            },
            watch : {
            },
            methods : {

                // 根据单位ID查询专家变动申请信息
                bindShenheList : function(){
                    var _this = this;

                    var biandong_layer = layer.open({type:3});
                    $.post('/system/renwu/findbdshenhelist', {
                        shenpideptid : _this.deptid,
                        zhuangtai : _this.zhuangtai,
                        biandongleixing : _this.biandongleixing,
                        deptname : _this.deptname,
                        xingming : _this.xingming,
                        xiafashijiankaishi : _this.xiafashijiankaishi,
                        xiafashijianjieshu : _this.xiafashijianjieshu,
                        wanchengshijiankaishi : _this.wanchengshijiankaishi,
                        wanchengshijianjieshu : _this.wanchengshijianjieshu,
                        pageindex : _this.pageindex,
                        pagesize : _this.pagesize,
                        rdm : Math.random()
                    },function(ppData) {
                        layer.close(biandong_layer);

                        if (ppData != null) {
                            var data = ppData.resultContent;
                            _this.shenhelist = data.shenhelist;

                            var pageInfo = data.PageInfo;
                            _this.pageindex = pageInfo.pageIndex;
                            _this.pageCount = pageInfo.pageCount;
                            _this.recordCount = pageInfo.recordCount;
                            _this.targetpage = '';
                        }
                    },"json");
                },

                //首页
                firstPage : function(){
                    this.pageindex = 1;
                },
                //尾页
                lastPage : function(){
                    this.pageindex = this.pageCount;
                },
                //上一页
                prePage : function(){
                    var prePage = ((this.pageindex -1) <= 0) ? 1 : (this.pageindex -1);
                    this.pageindex = prePage;
                },
                //下一页
                nextPage : function(){
                    var nextPage = ((this.pageindex +1) >= this.pageCount) ? this.pageCount : (this.pageindex +1);
                    this.pageindex = nextPage;
                },
                //跳到目标页
                targetPage : function() {
                    if( this.targetpage != '' && this.targetpage <= this.pageCount && this.targetpage > 0){
                        this.pageindex = this.targetpage;
                        this.targetpage = '';
                    }
                },

                showShenheModal:function(ppRenwuId){
                    var _this = this;

                    _this.renwuid = ppRenwuId;

                    $("#myModalLabel").html("专家变动申报审核");
                    $("#modal-dialog").attr("style", "width:1200px;");
                    $("#shenheModal").modal();
                },

                //审核
                shenhe:function(shenhezhuangtai){
                    var _this = this;
                    if (_this.checkInputData(shenhezhuangtai)) {
                        var biandong_layer = layer.open({type: 3});
                        $.post('/system/renwu/shenpi_zl', {
                            renwuid:_this.renwuid,
                            zhuangtai:shenhezhuangtai,
                            zhuanyideptid:_this.zhuanyideptid,
                            yijian:_this.shenheyijian,
                            rdm: Math.random()
                        }, function (ppData) {
                            layer.close(biandong_layer);
                            if (ppData != null) {
                                if (ppData.result == "1") {
                                    layer.open({
                                        time: 1000,
                                        btn: [],
                                        content: "审核成功!",
                                    });
                                    _this.bindShenheList();
                                    $("#shenheModal").modal('hide');
                                } else {
                                    layer.alert(ppData.message);
                                }
                            }
                        }, "json");
                    }
                },

                jieshou:function(renwuid){
                    var _this = this;
                    var biandong_layer = layer.open({type: 3});
                    $.post('/system/renwu/shenpi_zl', {
                        renwuid:renwuid,
                        zhuangtai:4,
                        zhuanyideptid:'',
                        yijian:'',
                        rdm: Math.random()
                    }, function (ppData) {
                        layer.close(biandong_layer);
                        if (ppData != null) {
                            if (ppData.result == "1") {
                                layer.open({
                                    time: 1000,
                                    btn: [],
                                    content: "接收成功!",
                                });
                                _this.bindShenheList();
                                $("#shenheModal").modal('hide');
                            } else {
                                layer.alert(ppData.message);
                            }
                        }
                    }, "json");
                },

                showDetailModal:function(ppShenbaoId){
                    var _this = this;

                    $("#DetailModalLabel").html("专家转隶详情");
                    $("#detailModal").modal();

                    _this.bindDetail(ppShenbaoId);
                },

                bindDetail:function(ppShenbaoId){
                    var _this = this;

                    var biandong_layer = layer.open({type:3});
                    $.post('/system/biandongshenbao/findcustomone', {
                        shenbaoid : ppShenbaoId,
                        rdm : Math.random()
                    },function(ppData) {
                        layer.close(biandong_layer);

                        if (ppData != null) {
                            var data = ppData.resultContent;
                            _this.biandong = data;
                        }
                    },"json");
                },

                showShenhejiluModel:function(ppShiwuId){
                    var _this = this;

                    $("#shenhejiluModalLabel").html("审核进度");
                    $("#shenhejiluModal").modal();

                    _this.bindShenhejilu(ppShiwuId);
                },

                bindShenhejilu:function(ppShiwuId){
                    var _this = this;

                    var biandong_layer = layer.open({type:3});
                    $.post('/system/renwu/findspjl', {
                        shiwuid : ppShiwuId,
                        rdm : Math.random()
                    },function(ppData) {
                        layer.close(biandong_layer);

                        if (ppData != null) {
                            var data = ppData;
                            _this.shenhejilulist = data.resultContent;
                        }
                    },"json");
                },

                /*工具*/
                checkInputData:function(shenhezhuangtai){
                    if (shenhezhuangtai==0){

                        if (!$.trim(this.shenheyijian)) {
                            layer.alert("请填写审核意见！");
                            return false;
                        }

                    }

                    return true;
                },

                refresh:function(){
                    var _this = this;
                    _this.zhuangtai = "";
                    _this.biandongleixing = "";
                    _this.deptname = "";
                    _this.xingming = "";
                    _this.xiafashijiankaishi = "";
                    _this.xiafashijianjieshu = "";
                    _this.wanchengshijiankaishi = "";
                    _this.wanchengshijianjieshu = "";
                },

                getDate_chaxun:function(){
                    var _this = this;

                    _this.xiafashijiankaishi=$("#xiafashijiankaishi").val();
                    _this.xiafashijianjieshu=$("#xiafashijianjieshu").val();
                    _this.wanchengshijiankaishi=$("#wanchengshijiankaishi").val();
                    _this.wanchengshijianjieshu=$("#wanchengshijianjieshu").val();
                },

                bindDeptList:function(){
                    var _this = this;

                    var biandong_layer = layer.open({type:3});
                    $.post('/system/deptxinxi/customlist', {
                        parentid : _this.deptid,
                        rdm : Math.random()
                    },function(ppData) {
                        layer.close(biandong_layer);

                        if (ppData != null) {
                            var data = ppData;
                            _this.deptlist = data.resultContent;
                        }
                    },"json");
                },

                Export:function(){
                    var _this = this
                    location.href = "/system/daochu/bdshenhexinxi?shenpideptid="+_this.deptid
                        +"&zhuangtai="+_this.zhuangtai
                        +"&biandongleixing="+_this.biandongleixing
                        +"&deptname="+_this.deptname
                        +"&xingming="+_this.xingming
                        +"&xiafashijiankaishi="+_this.xiafashijiankaishi
                        +"&xiafashijianjieshu="+_this.xiafashijianjieshu
                        +"&wanchengshijiankaishi="+_this.wanchengshijiankaishi
                        +"&wanchengshijianjieshu="+_this.wanchengshijianjieshu
                },
            },
        })
    </script>
</body>
</html>